package titt.server;

import titt.server.func.ServiceErrorDetection;
import titt.server.func.ServiceRegistration;
import titt.server.func.ServiceRequest;
import titt.server.func.ServiceSync;
import titt.server.func.ServiceRequestHelper;
import titt.server.func.ServiceSyncHelper;
import titt.server.func.ServiceUnregistration;
import titt.server.func.ServiceWithdraw;
import titt.server.func.util.DoNothingFunction;
import titt.server.func.util.Gensym;
import titt.server.func.util.ListServices;
import titt.server.os.ObjectServer;
import titt.server.service.db.ServerDatabaseImpl;
import titt.server.service.db.TITTDBEventDispatcher;

public class TITTServer {
	
	public ServerJob createServerJob() {
		ObjectServer titt = new ObjectServer("titt");
		
		titt.setServerDatabase(new TITTDBEventDispatcher(titt, new ServerDatabaseImpl()));
		
		ServerJob sj = new ServerJobImpl(titt, 
				new ServiceRequest(), 
				new ServiceRequestHelper(), 
				new ServiceRegistration(), 
				new ServiceUnregistration(),  
				new ServiceSync(), 
				new ServiceSyncHelper(), 
				new ServiceWithdraw(), 
				new ServiceErrorDetection(), 
				new DoNothingFunction(), 
				new ListServices(), 
				new Gensym()
		);
		
		return sj;
		
	}
	
	public static void start() {

		TITTServer ts = new TITTServer();
		

		Server s = new Server(ts.createServerJob());
		s.start();
	}

}
